package by.averianov.discounta.datamodel;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.MapsId;
import javax.persistence.OneToOne;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

import by.averianov.discounta.datamodel.enums.AccessGroup;

@Entity
public class UserProfile extends AbstractEntity {

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Long id;
	@Column
	@NotNull
	@Size(max = 30)
	private String userFirstName;
	@Column
	@NotNull
	@Size(max = 30)
	private String userLastName;
	@Column
	private Long userDateCreated;
	@Column
	@Size(max = 9)
	private Long phoneNumber;
	@Column
	@Enumerated(EnumType.ORDINAL)
	private AccessGroup accessGroup;
	
	public Long getUserDateCreated() {
		return userDateCreated;
	}

	public void setUserDateCreated(Long userDateCreated) {
		this.userDateCreated = userDateCreated;
	}

	public AccessGroup getAccessGroup() {
		return accessGroup;
	}

	public void setAccessGroup(AccessGroup accessGroup) {
		this.accessGroup = accessGroup;
	}

	@MapsId
	@OneToOne(fetch = FetchType.LAZY, cascade = { CascadeType.PERSIST, CascadeType.MERGE })
	@JoinColumn(updatable = false, name = "id")
	private UserAccount userAccount;
		
	public Long getId() {
		return id;
	}

	public String getUserFirstName() {
		return userFirstName;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public void setUserFirstName(String userFirstName) {
		this.userFirstName = userFirstName;
	}

	public String getUserLastName() {
		return userLastName;
	}

	public void setUserLastName(String userLastName) {
		this.userLastName = userLastName;
	}

	public UserAccount getUserAccount() {
		return userAccount;
	}

	public void setUserAccount(UserAccount userAccount) {
		this.userAccount = userAccount;
	}

	public Long getPhoneNumber() {
		return phoneNumber;
	}

	public void setPhoneNumber(Long phoneNumber) {
		this.phoneNumber = phoneNumber;
	}

}
